<template>
  <div align="center">
    <h2 align="center">管理员会员登录列表</h2>
    会员名称:<input type="text" placeholder="请输入会员名称" v-model="state.name"/>
    年龄:<input type="text" placeholder="请输入年龄" v-model="state.age"/>--<input type="text" v-model="state.age"/>
    <input type="button" value="查询" @click="getList"/>
    <table border="1" align="center">
      <tr>
        <td>会员名称</td>
        <td>账号</td>
        <td>年龄</td>
        <td>头像</td>
        <td>出生日期</td>
        <td>状态</td>
        <td>操作</td>
      </tr>
      <tr v-for="item in list">
        <td>{{item.a_Name}}</td>
        <td>{{item.a_Zhang}}</td>
        <td>{{item.a_Age}}</td>
        <td>{{ item.a_Photo }}</td>
        <td>{{item.a_Date.split("T")[0]}}</td>
        <td>{{item.a_State==1?"开启":"停用"}}</td>
        <td>
          <input type="button" value="修改" @click="UpdateInfo(item.a_Id)"/>
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { onMounted, reactive,toRefs } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router = useRouter()

let data:any = reactive({
  state:{
    name:'',
    age:''
  },
  list:[],
})
let {state,list} = toRefs(data)

onMounted(()=>{
  getList()
})

const getList=()=>{
  axios({
    url:"/api/Member/GetAdminInfo",
    method:'get',
    params:state.value
  })
  .then(res=>{
    console.log(res)
    list.value = res.data.data
  }).catch(err=>{
    console.log(err)
  })
}

const UpdateInfo=(id:any)=>{
  router.push({
    path:'/adminUpdate',
    query:{
      id:state.value.a_Id
    }
  })
}
</script>

<style scoped>

</style>